<template>
	<view>
		<view class="header">
			<image class="back" @click="back" src="../../static/langwen/back.png" mode=""></image>
			<view class="flexbox">
				<image class="icon" src="../../static/langwen/search.png" mode=""></image>
				<input class="input" type="text" placeholder-class="input" placeholder="搜索" v-model="keyword"/>
			</view>
			<view class="submit" @click="searchHandle">
				搜索
			</view>
		</view>
        <filters ref="filters"></filters>
	</view>
</template>

<script>
import filters from '@/components/langwen/filter.vue';
export default {
	name: 'search',
    onShow() {
        this.$clound.cloudEvent('hideExistFrm');
    },
    onHide() {
        this.$clound.cloudEvent('showExistFrm');
    },
    onUnload() {
        this.$clound.cloudEvent('showExistFrm');
    },
    components: {
        filters
    },
	// 下拉刷新回调函数
	onPullDownRefresh() {
		this.$refs.filters.getListData('headerRefreshing');
		uni.stopPullDownRefresh();
	},
	// 上拉加载
	onReachBottom() {
		this.$refs.filters.getListData('load');
	},
    data() {
        return {
            keyword: ''
        }
    },
    methods: {
        // 返回上一页
        back() {
            // uni.navigateBack();
            window.history.go(-1)
        },
        // 搜索
        searchHandle() {
            if(this.keyword === '') {
                this.$common.fnToast('关键字不能为空');
                return;
            };
            this.$nextTick(function() {
                this.$refs.filters.keyword = this.keyword;
                this.$refs.filters.getListData('headerRefreshing');
            });
        }
    }
}
</script>

<style lang="less">
.header {
	display: flex;
	align-items: center;
	height:44px;
	background:rgba(90,194,255,1);
	.back {
		width: 44px;
		height: 44px;
		min-width: 44px;
		margin-right: 10px;
	}
	.flexbox {
		flex-grow: 1;
		display: flex;
		align-items: center;
		height:30px;
		background:rgba(255,255,255,0.26);
		border-radius:19px;
		.icon {
			width: 15px;
			height: 15px;
			margin: 0 9px 0 16px;
		}
		.input {
			flex-grow: 1;
			font-size:14px;
			font-weight:500;
			color:rgba(255,255,255,1);
		}
	}
	.submit {
		font-size:15px;
		font-weight:500;
		color:rgba(255,255,255,1);
		margin: 0 15px;
        min-width: 34px;
	}
}
</style>
